import axios from 'axios';

// 创建一个 Axios 实例
const axiosInstance = axios.create({
  baseURL: 'http://localhost:8090', // 替换成您的 API 地址
  timeout: 5000, // 设置请求超时时间（单位：毫秒）
  // headers: {
  //   'Content-Type': 'application/json', 
  // },
  // headers: {'Content-Type': 'multipart/form-data;charset=utf-8'},
  changeOrigin:true
});
const axiosInstanceforbundary = axios.create({
  baseURL: 'http://localhost:8090', // 替换成您的 API 地址
  timeout: 5000,
  method:'post',
  headers: {'Content-Type': 'multipart/form-data;charset=utf-8'},
  changeOrigin:true
});
// 添加响应拦截器
axiosInstance.interceptors.response.use(
  (response) => {
    // 对响应数据做些什么，例如解析响应数据等
    return response;
  },
  (error) => {
    // 对响应错误做些什么，例如处理错误提示等
    return Promise.reject(error);
  }
);

// 管理员api
//1.管理员登录
export function postAdminLogin(admin){
  return axiosInstance.post(`/admin/login`,admin)
}
//管理员修改密码
export function updateAdminPassword(admin){
  return axiosInstance.put(`/admin/updatePwd`,admin)
}
// 医生业务api
// 获取医生信息列表
export function getDoctors(){
  return axiosInstance.get(`/doctors/getDoctors`)
}
// 添加医生
export function addDoctor(docter){
  return axiosInstance.post(`/doctors/addDoctor`,docter)
}
// 编辑修改医生信息
export function updateDoctor(docter){
  return axiosInstance.put(`/doctors/updateDoctor`,docter)
}
// 逻辑删除医生（医生离职）
export function delDoctor(doctor_id){
  return axiosInstance.get(`/doctors/delDoctor/${doctor_id}`)
}
// 根据名字查找医生
export function getDoctorByName(docter_name){
  return axiosInstance.get(`/doctors/getDoctorByName/${docter_name}`,)
}
// 用户业务api
// 获取用户列表
export function getUserList(){
  return axiosInstance.get(`/users/getAll`)
}
//更新用户信息
export function updateUserInfo(user){
  return axiosInstance.put(`/users/updateUserInfo`,user)
}
//通过用户名获取用户数据
export function getUserInfoByUsername(username){
  return axiosInstance.get(`/users/getUserInfoByUsername/${username}`)
}
//预约服务记录api
export function getAppointmentDetailList(){
  return axiosInstance.get(`/appointment/getDetailList`)
}
//根据预约id获取对应数据
export function getAppointmentById(appointment_pkid){
  return axiosInstance.get(`/appointment/get/${appointment_pkid}`)
}
//根据预约id修改服务状态
export function updateAppointmentStatus(appointment_pkid,status){
  return axiosInstance.get(`/appointment/update/${appointment_pkid}/${status}`)
}
//根据预约时间查询预约列表
export function getAppointmentListByAppointmentTime(appointment_time){
  return axiosInstance.get(`/appointment/getAppointmentListByAppointmentTime/${appointment_time}`)
}
//根据预约用户名进行查询
export function getAppointmentListByUsername(username){
  return axiosInstance.get(`/appointment/getAppointmentListByUsername/${username}`)
}
// 服务记录api
// 增加服务记录
export function addServiceRecord(serviceRecord){
  return axiosInstance.post(`/serviceRecords/addServiceRecord`,serviceRecord)
}
//获取服务记录列表
export function getAllDetails(){
  return axiosInstance.get(`/serviceRecords/getAllDetails`)
}
//修改服务状态
export function updateServiceRecord(record_id){
  return axiosInstance.get(`/serviceRecords/updateServiceRecord/${record_id}`)
}

// 医疗诊断记录api
// 增加诊断记录
export function addMedicalRecord(medicalRecord){
  return axiosInstance.post(`/medicalRecord/addMedicalRecord`,medicalRecord)
}
// 获取医疗记录
export function getAllMedicalRecord(){
  return axiosInstance.get(`/medicalRecord/getAll`)
}
//根据订单号获取医疗记录
export function getAllMedicalRecordByOrderNumber(orderNumber){
  return axiosInstance.get(`/medicalRecord/getAllMedicalRecordByOrderNumber/${orderNumber}`)
}
// 服务类型api
//获取服务类型列表
export function getAllServiceDetails(){
  return axiosInstance.get(`/servicedetails/all`)
}
//修改服务的上下架状态
export function changeStatus(service_detail_id){
  return axiosInstance.get(`/servicedetails/changeStatus/${service_detail_id}`)
}
//修改服务内容
export function updateServicedetail(servicedetail){
  return axiosInstance.put(`/servicedetails/update`,servicedetail)
}
//根据项目名称获取数据
export function getDetailByName(service_name){
  return axiosInstance.get(`/servicedetails/getDetailByName/${service_name}`)
}
//添加新的服务insertServiceDetail
export function insertServiceDetail(serviceDetail){
  return axiosInstance.post(`/servicedetails/insertServiceDetail`,serviceDetail)
}
//服务大类型api
//获取服务大类型列表
export function getServiceCategoties(){
  return axiosInstance.get(`/servicecategories/all`)
}

//控制台页面需要的数据
//系统注册使用人数
export function getUserCounts(){
  return axiosInstance.get(`/users/getUserCounts`)
}
//宠物数量
export function getPetCounts(){
  return axiosInstance.get(`/pets/getPetCounts`)
}
//预约总量
export function getAppointmentCounts(){
  return axiosInstance.get(`/appointment/getAppointmentCounts`)
}
//预约完成数量
export function getServiceRecordsCounts(){
  return axiosInstance.get(`/serviceRecords/getServiceRecordsCounts`)
}
//诊疗记录数量
export function getMedicalRecordsCounts(){
  return axiosInstance.get(`/medicalRecord/getMedicalRecordsCounts`)
}
//echarts表数据，为预约中各个项目的个数getAppointmentType
export function getAppointmentType(){
  return axiosInstance.get(`/appointment/getAppointmentType`)
}
//获取今日需要处理的预约数
export function getTodayAppointmentsCount(){
  return axiosInstance.get(`/appointment/getTodayAppointmentsCount`)
}